﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimCMS.Common
{
    public enum MessageType
    {
        Info,// Information
        Error, // Error
        Waring,  //Waring
        Question //question
    }
    public static class MessageHelper
    {
        /// <summary>
        /// Message help function
        /// Response the string to ajax js
        /// </summary>
        /// <param name="pages"></param>
        /// <param name="Messge"></param>
        /// <param name="typs">MessageType</param>
        public static SimCMS.Model.CommonModel.MessageModel SendMessge(string Messge, MessageType typs,bool IsCurrentClose,string navTabId)
        {
            var Model= ConfigTitle(typs, Messge);
            if (IsCurrentClose)
            {
                Model.callbackType = "closeCurrent";
            }
            Model.navTabId = navTabId;
            return Model;
        }


        public static SimCMS.Model.CommonModel.MessageModel SendMessge(string Messge, MessageType typs, bool IsCurrentClose)
        {
            var Model = ConfigTitle(typs, Messge);
            if (IsCurrentClose)
            {
                Model.callbackType = "closeCurrent";
            }
            return Model;
        }
        /// <summary>
        /// Message help function
        /// Response the string to ajax js
        /// </summary>
        /// <param name="pages"></param>
        /// <param name="Messge"></param>
        /// <param name="typs"></param>
        /// <param name="ReturnUrl"> return url</param>
        public static SimCMS.Model.CommonModel.MessageModel SendMessge(string Messge, MessageType typs, string ReturnUrl)
        {
           return ConfigTitle(typs, Messge);
        }

        


        private static SimCMS.Model.CommonModel.MessageModel ConfigTitle(MessageType typs,string Message)
        {
            SimCMS.Model.CommonModel.MessageModel Model = new SimCMS.Model.CommonModel.MessageModel();
            if (typs == MessageType.Info)
            {
                //提示消息
                Model.message = Message;
                Model.statusCode = "200";
            }
            else if (typs == MessageType.Error)
            {
                //操作错误
                Model.message = Message;
                Model.statusCode = "200";
            }
            else if (typs == MessageType.Waring)
            {
                //操作错误
                Model.message = Message;
                Model.statusCode = "200";
            }
            else if (typs == MessageType.Question)
            {
                //询问
                Model.message = Message;
                Model.statusCode = "200";
            }
            else
            {
                Model.message = Message;
                Model.statusCode = "200";
            }
            return Model;
        }
    }
}
